<% @Language="javascript"  %>

<!--#include file="../inc/mylib.vbs"-->

<!--#include file="../common/usersettings.vbs"-->
<!--#include file="../common/usersettings.js"-->

<script type="text/javascript" language="javascript" runat="server" src="../_ScriptLibrary/json-lib/json.js" charset="windows-1251"></script>
<script type="text/javascript" language="javascript" runat="server" src="../_ScriptLibrary/json-lib/json_content.js" charset="windows-1251"></script>
<script type="text/javascript" language="javascript" runat="server" src="../inc/request.js" charset="windows-1251"></script>
<script type="text/javascript" language="javascript" runat="server" src="../HHHGraph/eng6graphE-plan.js" charset="windows-1251"></script>

<script type="text/javascript" language="javascript" runat="server" charset="windows-1251">
    //debugger

    var content = _REQ.param("task")
    if ((typeof (content) == "object") && (content.Count > 0)) {
        var jsonRes = {}
        
        switch (content.Item) {
            case "GetUserSettings":
                jsonRes = GetUserSettings (_REQ.param("source").Item, _REQ.param("parametr").Item)
                break
            case "name_organization":
                //debugger

                jsonRes = strjson.code (GetNameOrganization ())
                break
            case "server_name":
                //debugger

                jsonRes["ServerName"] = Server.CreateObject("WScript.Network").ComputerName

                break
            case "server_ip":
                jsonRes = server_ip ()
                break
            case "server_info":
                //debugger

                jsonRes = server_info("../settings/settings.xml")
                break
            case "server_typedesc":
                //debugger

                jsonRes = server_typedesc("../settings/settings.xml")
                break
            case "redirect":
                //debugger

                jsonRes["href"] = GetStrParams(_REQ.param("search").Item.split ("=") [1])
                break
            case "rdg_fullpath":
                jsonRes = getDirXLSPlanKaskad() + makeNameXLSPlanKaskad (new Date ())
                break
            case "sdd_port":
                //debugger

                var xmldom = Server.CreateObject("Microsoft.XMLDOM"),
                    reg

                xmldom.async = false
                try { xmldom.load(Server.MapPath("../settings/settings.xml")) }
                catch (err) { }

                if (typeof (err) == "undefined") {
                    reg = xmldom.getElementsByTagName("portSDD") [0]

                    jsonRes = {"port": reg.attributes.getNamedItem("port").value}
                }
                else
                    jsonRes = { "error": err.description, "port": 5001 }
                break
            default:
                ;
        }

        Response.Write(JSON.stringify(jsonRes))
    }
    else
        ;
</script>
